/*
 * @Author: scl
 * @Date: 2023-07-06 10:16:56
 * @LastEditTime: 2023-07-06 22:13:26
 * @Description: file content
 */
import { defineConfig,loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'

// https://vitejs.dev/config/
export default defineConfig(({ mode, command }) =>{
  const env = loadEnv(mode, process.cwd());
  const { VITE_APP_BASE_API, VITE_SERVE } = env;
  return {
  plugins: [vue()],
  resolve: {
    alias: {
      "@": path.resolve("./src") // 相对路径别名配置，使用 @ 代替 src
    }
  },
  server:{
    host:'0.0.0.0',
    port:5500,
    proxy:{
      [VITE_APP_BASE_API]:{
        target:VITE_SERVE,
        changeOrigin:true,
        rewrite:(path)=>path.replace(/^\/api/,"")
      }
    }
  }
}
})
